<script setup lang='ts'>
import { showFailToast } from "vant";
import { ref, onMounted } from "vue"
import { useRouter } from "vue-router";
const $router = useRouter()
const active = ref<any>(0);
const AllBuy = ref<any>(localStorage.getItem('chapter-buy') ? JSON.parse(`${localStorage.getItem('chapter-buy')}`) : [])
const onClickTab = () => {
    console.log(1);
}
onMounted(() => {
})

const toBookContent = (item: any) => {
    showFailToast('资源缺失！')
}

const activeName = ref<any>('1')
</script>

<template>
    <div class="buy-upload">
        <div class="title">
            <img src="@/assets/imgs/返回1.png" alt="" @click="$router.back()">
            <span>已购和上传</span>
            <span></span>
        </div>
        <van-tabs v-model:active="active" @click-tab="onClickTab" class="content">
            <van-tab title="已购">
                <van-collapse v-model="activeName" accordion :border="false">
                    <van-collapse-item v-for="(book, index) in AllBuy" :key="book.book" :title="book.title"
                        :name="index" :border="false" size="large">
                        <ul class="list">
                            <li v-for="(item, index) in book.chapters" :key="index" @click="toBookContent(item)">

                                <p>{{ item.title }}</p>
                            </li>
                        </ul>
                    </van-collapse-item>

                </van-collapse>
            </van-tab>
            <van-tab title="上传">
                <div class="upload-content">
                    <p>内容缺失！</p>
                </div>
            </van-tab>
        </van-tabs>
    </div>
</template>

<style lang="less" >
span {
    color: #333;
}

.buy-upload {
    width: 100vw;
    height: 100vh;

    >.title {
        display: flex;
        height: 50rem;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid #eee;

        img {
            width: 30rem;
            height: 30rem;
        }

        span {
            font-size: 17rem;
            color: #333;
        }

    }

    >.content {
        .van-tab {
            span {
                color: #333;
                font-size: 16rem;
            }
        }

        .van-cell__title {
            span {
                font-size: 16rem;
            }
        }

        .van-tabs__line {
            background-color: #333;
        }

        ul.list {
            li {
                margin-bottom: 10rem;
            }
        }



        .upload-content {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-top: 150rem;
            // text-align: center;
        }
    }


}
</style>
